# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : p1.py
# @Time     : 2024/5/7 22:38
# @Author   : Robot-Zsj
"""
description:

https://fcqian.blog.csdn.net/article/details/127204355


i:
1,3,3,3,2,4,4,4,5

o:
3,4,1,2,5
"""

arr = input().split(",")


def getResult(arr):
    count = {}  # 数字出现的次数
    first = {}  # 数字第一次出现的位置

    for i in range(len(arr)):
        s = arr[i]

        if count.get(s) is None:
            count[s] = 0

        count[s] += 1

        if first.get(s) is None:
            first[s] = i
    tmp = list(first.keys())
    tmp.sort(key=lambda x: (-count[x], first[x]))
    return ",".join(tmp)


print(getResult(arr))
